/*
 * @Description:
 * @Version: 1.0
 * @Autor: gaoluo
 * @Date: 2021-09-30 11:03:25
 * @LastEditors: gaoluo
 * @LastEditTime: 2021-11-04 14:33:39
 * @FilePath: /nhw/src/utils/uploadImages.js
 */
import { uploadImage } from '@/api/work.js'
import axios from 'axios';

function mapId(res) {
  return res.map((item) => item.param.data.id)
}
export default async function (filelist) {
  const uploadProm = [];
  filelist.forEach((item) => {
    const formData = new FormData();
    formData.append('file', item.file);
    uploadProm.push(uploadImage(formData));
  });

  const res = await axios.all(uploadProm)

  return mapId(res)
}